import { handleActions } from "redux-actions"

const initState = {
    list: []
}

// 原始的reducer写法
function oldReducer(state = initState, action) {
    switch (action.type) {
        case "module-list/success-got-list":
            console.log("reducer action 被触发", action)
            return {
                ...state,
                list: action.list
            }
        default:
            return state
    }
}

console.log("reducer", oldReducer)

const reducer = handleActions(
    {
        "module-list/success-got-list": (state, action) => {
            console.log("reducer action 被触发", action)
            return { ...state, list: action.list }
        }
    },
    initState
)

export default reducer
